import { useRequest } from 'ahooks';
import { PropsWithChildren, useContext } from 'react';
import React, { createContext, useState } from 'react';

import { apiWinListByGet } from '@/application/apis/formatApi';
interface AwardListContextValue {
  [key: string]: any;
}

export const AwardListContext = createContext<AwardListContextValue>({});

export const AwardListProvider: React.FC<PropsWithChildren> = ({ children }) => {
  const { data: list, run: refreshAward } = useRequest(apiWinListByGet);

  return (
    <AwardListContext.Provider value={{ list, refreshAward }}>{children}</AwardListContext.Provider>
  );
};

/**
 * 当前用户状态
 */
const useAwardList = () => useContext(AwardListContext);
export { useAwardList };
